<meta charset="utf-8">
<table border="0" cellspacing="0" cellpadding="0" style="margin:0 0 50px 0;">
<form method="post" action="index.php">
  <tr>
   <td style="padding: 0px 10px 5px 10px">Họ Tên :</td>
    <td><input type="text" name="hoten" style="width:150px" value=""></td>
    <td style="padding: 0px 10px 5px 10px">Email :</td>
    <td><input type="text" name="email" style="width:150px" value=""></td>
     <td style="padding: 0px 10px 5px 10px">SDT :</td>
    <td><input type="text" name="sdt" style="width:150px" value=""></td>
  </tr>
   <tr height="30px">
    <td style="padding: 0px 10px 5px 10px">Ngày Sinh :</td>
    <td><input type="text" name="ngaysinh" style="width:150px" value=""></td>
    <td style="padding: 0px 10px 5px 10px">CMND :</td>
    <td  colspan="3"><input type="text" name="cmnd" style="width:150px" value=""></td>
  </tr>
  <tr>
  	<td class="ketthuc" colspan="3" height="35" align="center">
    <input type="hidden" name="actionadmin" value="Tìm Kiếm Thành Viên" />
    <input name="TimThanhVien" type="submit" value="Tìm Kiếm" class="button">
    <input name="" type="reset" value="Reset" class="button">  
    </td>
  </tr>
  </form>
</table>
<?php
if(isset($_REQUEST['TimThanhVien']))
{
		$hoten=isset($_POST["hoten"])?$_POST["hoten"]:"";
		$email=isset($_POST["email"])?$_POST["email"]:"";
		$dienthoai=isset($_POST["dienthoai"])?$_POST["sdt"]:"";
		$ngaysinh=isset($_POST["ngaysinh"])?$_POST["ngaysinh"]:"";
		$cmnd=isset($_POST["cmnd"])?$_POST["cmnd"]:"";
$wh=" and HoTen like '%$hoten%' ";
$wh.=" and Email like '%$email%' ";
$wh.=" and DienThoai like '%$dienthoai%' ";
$wh.=" and NgaySinh like '%$ngaysinh%' ";
$wh.=" and cmnd like '%$cmnd%' ";
$currentPage = isset($_REQUEST['curPage'])?$_REQUEST['curPage']:1;
$start = ($currentPage	-1) * $pagesize;		
$strSQL = "SELECT * FROM ThanhVien where 1".$wh." LIMIT  $start, $pagesize";
//echo $strSQL;
$result = mysql_query($strSQL);
$n=mysql_num_rows($result);
if($n>0)
{
?>
			<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
				<tr>
					<th class="table-header-repeat line-left minwidth-1" ><a href="">STT</a>	</th>
					<th class="table-header-repeat line-left"><a href="">Họ Tên</a></th>
					<th class="table-header-repeat line-left"><a href="">Email</a></th>
					<th class="table-header-repeat line-left"><a href="">Điện Thoại</a></th>
                    <th class="table-header-repeat line-left"><a href="">Ngày Sinh</a></th>
                    <th class="table-header-repeat line-left"><a href="">CMND</a></th>
					<th class="table-header-options line-left"><a href="">Tùy Chọn</a></th>
				</tr>
 <?php
 $i=$start;
while($r3 = mysql_fetch_assoc($result))
{
	$i++;
	$id=$r3["ThanhVienID"];
			$hoten=$r3["HoTen"];
			$email=$r3["Email"];
			$dienthoai=$r3["DienThoai"];
	   
			$ngaysinh=$r3["NgaySinh"];
			$cmnd=$r3["CMND"];
			
			?>
             <!--  -->
				<tr>
					<td><?php echo "$i"; ?></td>
					<td><?php echo "$hoten"; ?></td>
					<td><?php echo "$email"; ?></td>
					<td><?php echo "$dienthoai"; ?></td>
					<td><?php echo "$ngaysinh"; ?></td>
                    <td><?php echo "$cmnd"; ?></td>
					<td class="options-width">
					<a href="?actionadmin=Update Thành Viên&matv=<?php echo "$id"; ?>&curPage=<?php echo $currentPage; ?>" title="Edit" class="icon-1 info-tooltip"></a>
					<a href="?actionadmin=Delete Thành Viên&matv=<?php echo "$id"; ?>&curPage=<?php echo $currentPage; ?>" title="Delete" class="icon-2 info-tooltip"></a>
					</td>
				</tr>
   <?php 
   			}
    ?> 
  </table>
 <?php
$query = "SELECT count(*) as NUMROW FROM ThanhVien where 1".$wh." ";
$result = mysql_query($query);	
$row = mysql_fetch_array($result);
$numrow = $row[0];
$numpage = ceil($numrow / ($pagesize*1.0));

//Style 
echo "<h2>";
if ($numpage>1)
{
	$next = $currentPage + 1;
     $prev = $currentPage - 1;
	 if($currentPage!=1)
	 		echo "<a style='cursor:pointer'href='?actionadmin=Thành Viên&curPage=$prev'>Previous</a>&nbsp;&nbsp;&nbsp;"   ;  
for($i = 1 ; $i<= $numpage;$i++)
{
	if($i == $currentPage)
		echo $i."&nbsp;&nbsp;&nbsp;";
	else
	{
		echo "<a style='cursor:pointer' href='?actionadmin=Thành Viên&curPage=$i'>".$i."</a>&nbsp;&nbsp;&nbsp;";
	}
}
	 if($currentPage != $numpage)
            echo "<a style='cursor:pointer' href='?actionadmin=Thành Viên&curPage=$next'>Next</a>";
		echo "</h2>";
}
}
else
	{
		echo "<script>alert('Không tìm thấy kết quả nào phù hợp!');</script>";
	}
}
?>